﻿using PmSadis.Models.Abstract;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;

namespace PmSadis.Models
{
    /// <summary>
    /// Контракт подрядчика
    /// </summary>
    [Table("D_SUB_CONTRACT")]
    [MetadataType(typeof(SubContractMetadata))]
    public class SubContract : Contract
    {
        /// <summary>
        /// Идентификатор контракта
        /// </summary>
        public new int ContractId { get; set; }

        /// <summary>
        /// Наименование блока
        /// </summary>
        [Column("BLOCK_NAME")]
        public string BlockName { get; set; }

        /// <summary>
        /// Идентификатор генконтракта
        /// </summary>
        public virtual GenContract GenContract { get; set; }
        [Column("GEN_CONTRACT_ID")]
        public int? GenContractId { get; set; }

        /// <summary>
        /// Подрядчик контракта
        /// </summary>
        public virtual SubContractor SubContractor { get; set; }
        [Column("SUB_CONTRACTOR_ID")]
        public int? SubContractorId { get; set; }

        /// <summary>
        /// объекты контракта
        /// </summary>
        public ICollection<ObjectInContract> Objects { get; set; }
    }

    sealed class SubContractMetadata : ContractMetadata
    {
        [Column("SUB_CONTRACT_ID")]
        [Key]
        public new int ContractId { get; set; }
    }
}
